<?php
$lib_rupiah = new Format_rupiah();
?>
<div class="twelve columns">
    <div class="box_head">
        <h3><?php echo $title; ?></h3>
    </div>
    <div class="member">
        <?php
         if ($alert == "13") {
            ?>
            <section id="tagLine" class="clearfix">
                <div class="twelve columns">
                    <h5>
                        Terima kasih,,,, <br>
                        <small>Data Pemesanan anda berhasil kami simpan, Silahkan Melakukan Pembayaran.</small>
                    </h5>
                </div>
            </section>
        <?php } ?>
        <br/>
        <table width="100%" class="cart_table">
            <thead>
                <tr>
                    <th width="25%"><h4>Order ID</h4></th>
            <th><h4>Tgl Transaksi</h4></th>
            <th><h4>Biaya</h4></th>
            <th><h4>Status</h4></th>
            <th width="5%">&nbsp;</th>
            </tr>            
            </thead>
            <tbody>
                <?php
                $img_lihat = $this->lib_button->lihat_icon();
                foreach ($list_pemesanan as $list_pesan) {

                    $link_lihat = anchor('main/member/view_history_order_det/' . $list_pesan->id, $img_lihat);
                    echo "<tr>";
                    echo "<td align='center'><p> $list_pesan->id</p></td>";
                    echo "<td align='center'><p> $list_pesan->date</p></td>";
                    echo "<td align='right'> <p> " . $lib_rupiah->rupiah($list_pesan->grand_total) . "</p></td>";
                    if ($list_pesan->status == 2)
                        $status = "Sukses";
                    else if ($list_pesan->status == 1)
                        $status = "Gagal";
                    else {
                        $tgl1 = date('Y-m-d'); // 1 Oktober 2010

                        $pecah1 = explode("-", $tgl1);
                        $date1 = $pecah1[2];
                        $month1 = $pecah1[1];
                        $year1 = $pecah1[0];

                        $tgl2 = $list_pesan->date; // 10 Oktober 2010
                        $date2 = substr($tgl2, 8, 2);
                        $month2 = substr($tgl2, 5, 2);
                        $year2 = substr($tgl2, 0, 4);

                        $jd1 = GregorianToJD($month1, $date1, $year1);
                        $jd2 = GregorianToJD($month2, $date2, $year2);

                        //pengurangan jadi nilai hari
                        $selisih = $jd1 - $jd2;

                        if ($selisih <= 2)
                            $status = "Proses";
                        else
                            $status = "Gagal";
                    }
                    echo "<td align='center'><p><b> $status</b></p></td>";
                    echo "<td> $link_lihat </td>";
                    echo "</tr>";
                }
                ?>
            </tbody>
        </table>

    </div>
</div>